package de.mmis.core.pojop.processor;

import de.mmis.core.base.event.Event;
import de.mmis.core.base.event.Observable;
import de.mmis.core.pojop.answer.Answer;
import de.mmis.core.pojop.request.Request;

public interface RequestProcessorFactory<R extends Request> {

	public interface RequestProcessor<R extends Request> extends
			Observable<RequestProcessorFactory.RequestProcessorEvent> {
		public void init();

		public Answer answerRequest(R request);

		public void close();
	}

	public static class RequestProcessorEvent implements Event {
		private final Answer answer;

		public RequestProcessorEvent(Answer answer) {
			this.answer = answer;
		}

		public Answer getAnswer() {
			return this.answer;
		}
	}

	RequestProcessor<R> createRequestProcessor();
}
